package org.penguin.study.bk.elasticsearch.repository;

import org.penguin.study.bk.elasticsearch.entity.Product;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author chengyinghua
 */
@Repository
@ConditionalOnProperty(name = "elasticsearch.enable", havingValue = "true")
public interface ProductRepository
        extends ElasticsearchRepository<Product, String> {

    List<Product> findByName(String name);

    List<Product> findByNameContaining(String name);

    List<Product> findByManufacturerAndCategory
            (String manufacturer, String category);
}
